﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Game
    {
        public void Games()
        {
        
            Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入您的姓名：");
            string aname = Console.ReadLine();
            string name= "刘备";
           
            if (a == 2)
            {
                name = "孙权";
            }
            if (a == 3)
            {
                name = "曹操";
            }
            Console.WriteLine(aname + "VS" + name);
            int count = 1;//对战次数
            int score = 1;//得分
            int scores = 1;

            while (true)
            {
                Console.WriteLine("是否开始下一轮？<y/n>");
                string b = Console.ReadLine();
                if (b == "y")
                {
                    count++;
                    Console.WriteLine("请出拳：1.剪刀 2.石头 3.布 (输入相应数字：)");
                    int tap = int.Parse(Console.ReadLine());
                    string c = "剪刀";
                    if (tap == 2)
                    {
                        c = "石头";
                    }
                    if (tap == 3)
                    {
                        c = "布";
                    }
                    Random r = new Random();
                    int d = r.Next(1, 4);
                    string e = "剪刀";

                    if (d == 2)
                    {
                        e = "石头";
                    }
                    if (d == 3)
                    {
                        e = "布";
                    }
                    Console.WriteLine(aname + ": 出拳:" + c);
                    Console.WriteLine(name + ":出拳:" + e);
                    if (tap == d)
                    {
                        Console.WriteLine("和局");
                    }
                    if (tap==1)
                    {
                        if (d==2)
                        {
                            Console.WriteLine(aname+"输了");
                        }
                        if (d==3)
                        {
                            Console.WriteLine(aname+"赢了");
                        }
                    }
                    if (tap==2)
                    {
                        if (d==1)
                        {
                            Console.WriteLine(aname+"赢了");
                        }
                        if (d==3)
                        {
                            Console.WriteLine(aname+"输了");
                        }
                    }
                    if (tap==3)
                    {
                        if (d==1)
                        {
                            Console.WriteLine(aname+"输了");
                            score++;
                        }
                        if (d==2)
                        {
                            Console.WriteLine(aname+"赢了");
                            scores++;
                        }
                    }
                }
                if (b=="n")
                {
                    Console.WriteLine("===================================");
                    Console.WriteLine(aname + "VS" + name);
                    Console.WriteLine("对战次数"+count);
                    Console.WriteLine("姓名        得分");
                    Console.WriteLine(aname+"      "+scores);
                    Console.WriteLine(name+"       "+score);
                    if (score>scores)
                    {
                        Console.WriteLine(name+"赢,"+aname+"笨蛋");
                    }
                    else
                    {
                        Console.WriteLine(name + "笨蛋," + aname + "赢");
                    }
                    break;
                }
            }
        }
        
    }
}
